package logic

import (
	"context"
	"safe-hub/models/mysql"

	"safe-hub/assrpc/assrpc"
	"safe-hub/assrpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type LsitLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewLsitLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LsitLogic {
	return &LsitLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 关联列表
func (l *LsitLogic) Lsit(in *assrpc.LsitRequest) (*assrpc.LsitResponse, error) {
	// todo: add your logic here and delete this line
	/*
		SELECT
		*
		FROM
		calls LEFT JOIN users ON users.id=calls.pid
	*/
	var call mysql.Call
	mysql.DB.Debug().
		Joins("calls LEFT JOIN users ON users.id=calls.pid").
		Find(&call)

	return &assrpc.LsitResponse{
		Name: call.Name,
		Pass: int64(call.Pass),
		Shu:  int64(call.Shu),
		Pid:  int64(call.Pid),
	}, nil
}
